package com.management.department.teacherinfosystem.Entity;

import java.util.Date;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import jakarta.persistence.Table;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import lombok.Data;

@Data
@Entity
@Table(name = "user_talent_honor")
public class TalentHonor {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column(name = "user_id", nullable = false)
	private Long userId; // 关联 user.id（入选者）

	@Column(name = "category", length = 32)
	private String category; // 人才计划 / 荣誉称号

	@Column(name = "title_full_name", length = 255)
	private String titleFullName; // 称号全称

	@Column(name = "granting_organization", length = 255)
	private String grantingOrganization; // 授予单位

	@Temporal(TemporalType.DATE)
	@Column(name = "selection_date")
	private Date selectionDate; // 入选时间

	@Temporal(TemporalType.DATE)
	@Column(name = "valid_from")
	private Date validFrom; // 有效期起

	@Temporal(TemporalType.DATE)
	@Column(name = "valid_to")
	private Date validTo; // 有效期止

	@Column(name = "is_permanent")
	private Boolean isPermanent; // 是否长期/终身有效

	@Column(name = "notes", length = 500)
	private String notes; // 备注

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_at")
	private Date createdAt;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "updated_at")
	private Date updatedAt;

	@PrePersist
	public void prePersist() {
		Date now = new Date();
		if (createdAt == null) createdAt = now;
		updatedAt = now;
		if (isPermanent == null) isPermanent = Boolean.FALSE;
	}

	@PreUpdate
	public void preUpdate() {
		updatedAt = new Date();
	}
} 